home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 293 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: zippy.cais.net!news
  2. From: mgeiger@mail.drsystems.com (Mark Geiger)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: extern and static are they compatable
  5. Date: Thu, 04 Jan 1996 04:23:14 GMT
  6. Organization: Capital Area Internet Service info@cais.com 703-448-4470
  7. Message-ID: <4cfnu5$she@zippy.cais.net>
  8. References: <4cedhf$g6i@cnn.cc.biu.ac.il> <ahicksDKM8Ap.FBp@netcom.com>
  9. Reply-To: mgeiger@mail.drsystems.com
  10. NNTP-Posting-Host: 205.252.35.152
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. ahicks@netcom.com (Aaron Hicks at Netcom) wrote:
  14.  
  15. >Folks,
  16.  
  17. >  I'm working on a project which requires use to create large array 
  18. >( approximately 500 K bytes ) so we decided to make it static so it would  
  19. >not have be created each time the routines that use it are called.  We then
  20. >found out that we needed a nother program to acess this array so in the second
  21. >file we defined this array as a extern.  Now each time we compile and link 
  22. >the programs we get an error stating that the array is undefined.  The error
  23. >is displayed while linking.  After reading all I could find about extern 
  24. >I can not find any thing that says this is correct behavior. 
  25.  
  26. This is correct behavior.  When an object (variable, function, etc) is
  27. declared as static its scope is limited to the module (source file) in
  28. which it is defined.
  29.  
  30. > I then changed 
  31. >the static decloration to a non static and the thing compiles with out a 
  32. >problem. 
  33.  
  34. This is the correct way to do what you intend.
  35.  
  36. > Now I'm wandering if any of the great mind on the net could 
  37. >enlighten me as to why the static declaration would cause this error.  
  38. >Below is a short part of the code that shows the declarations of the array.
  39.  
  40. >header_file.h
  41. >...
  42.  
  43. >typedef char   Bit_Fail_Array_Type[Row_Max][Column_Max_By_Byte][Sub_Array_Max];
  44. >...
  45.  
  46. >raster.c
  47. >...
  48. >/* Global declaration of the array to hold the failed bits */
  49. >static Bit_Fail_Array_Type bit_fail_array_table;
  50. >...
  51.  
  52. >raster_analysis.c
  53. >...
  54. >/* Declare the array that hold the failed bits to analysis */
  55. >extern Bit_Fail_Array_Type bit_fail_array_table;
  56. >...
  57.  
  58.  
  59. >Thanks in Advance and Happy New Year
  60.  
  61. >Aaron Hicks
  62. >ahicks@netcom.com
  63.  
  64.  
  65.